package reflect;

import java.lang.reflect.Field;
import java.util.Arrays;

public class ReflectDemo9 {
    public static void main(String[] args) throws Exception {
        String s1 = "hello";
        String s2 = "hello";
        System.out.println(s1 == s2);

        Class<?> cls = String.class;

        Field field = cls.getDeclaredField("value");
        field.setAccessible(true);
        char[] array = (char[]) field.get(s1);
        System.out.println(Arrays.toString(array));

        char[] array2 = new char[]{'j', 'a', 'v', 'a'};
        field.set(s1, array2);

        System.out.println(s1);
        System.out.println(s2);

        String s3 = new String("hello");
        System.out.println(s3);

        System.out.println("hello");
        String s = "java";
        System.out.println("hello"+s+"java");
    }
}
